use serde::{Deserialize, Serialize};
use super::alias_dict::AliasDict;

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct FullConfig {
  pub alias_list: Vec<AliasDict>,
}

impl FullConfig {
  pub fn find_target(&self, cmd_id: &str) -> Option<AliasDict> {
    let result_one = self.alias_list.iter().find(|one_alias| {
      let option_name = one_alias.alias_name_list.iter().find(|one_name| {
        return (*one_name).eq(cmd_id);
      });
      option_name.is_some()
    });
    if result_one.is_none() {
      return None;
    }
    return Some(result_one.unwrap().clone());
  }  
}
